package com.tistory.admin.common.util;

import java.io.File;
import java.io.FileInputStream;
import java.text.NumberFormat;
import java.util.HashMap;

import jxl.Cell;

import org.apache.poi.hssf.usermodel.HSSFCell;
import org.apache.poi.hssf.usermodel.HSSFRow;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.xssf.usermodel.XSSFCell;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.tistory.commons.utils.FTPUtil;
import com.tistory.transfer.controller.TransferController;

public class Test {
	private static final Logger log = LoggerFactory.getLogger(Test.class);
	public static void main(String[] args) throws Exception {

		boolean test = testfileUpload("","");
		
		log.info("____________"+test);
	}
	
	
	/**
	 * 파일업로드
	 * 
	 * @param filePath
	 * @param targetList
	 * @return
	 */
	private static boolean testfileUpload(String filePath, String fileName) {
		log.info("[AutoPaymentrReqMain] writeFile()  filePath : " + filePath);
		filePath ="C:/Users/Public/Pictures/Sample Pictures/";
		fileName ="12.xls";
		String host = "118.223.61.231";
		String userName = "khs7999";
		String password = "go3169";
		int port = 21;

		// FTPUtil ftpUtil = new FTPUtil(Config.getValue("omp.payplanet.req.path"), fileName);
		FTPUtil ftpUtil = new FTPUtil("TEST", fileName);

		boolean result = false;

		// PayPlanet서버 접속
		if (!ftpUtil.connectionFtp(host, port)) {
			return result;
		}

		// 서버로그인
		if (!ftpUtil.loginFtp(userName, password)) {
			return result;
		}

		// 디렉토리 이동 및 생성
		ftpUtil.setWorkDirectory("/", "U");

		// 파일업로드
		if (ftpUtil.uploadFile(new File(filePath + fileName))) {
			result = true;
		}

		// 서버로그아웃
		ftpUtil.logoutFtp();

		// 서버접속 종료
		ftpUtil.ftpDisconnect();

		return result;
	}	
}